#include<pcap.h>
#include<boost/thread/thread.hpp>

using namespace std;
using namespace boost;

class PacketListener {
  public:
	PacketListener(string* destination, string* device, string* filter);
	virtual ~PacketListener();
	virtual void packetHandler(const u_char* packet, bpf_u_int32 len) = 0;;
	void run();
	void stop();
	void setFilter(string* filter) {
		this -> filter = filter;
	};
  protected:
	string* destinationIP;
	string* device;
	thread* lt;
	bool stopFlag;
	int offset;
	char* err;
	pcap_t* pcapHandle;
	string* filter;
	bpf_u_int32* mask;
	bpf_u_int32* net;
	bpf_program* fProg;
	pcap_pkthdr* header;
};
